home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / button12.zip / EXAMPLE.ZIP / EXAMPLE.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-21  |  7KB  |  308 lines

  1.  
  2. {Regen_FileHeader}
  3. {Regen_FileHeader}
  4.  
  5.  
  6.       {******************************************************************}
  7.       {   Source File: EXAMPLE.pas                                       }
  8.       {   Description: Pascal Source file for Example application        }
  9.       {   Date:        Mon Dec 21 14:38:38 1992                          }
  10.       {******************************************************************}
  11.  
  12.  
  13. program Example;
  14.  
  15. {$R EXAMPLE.RES}
  16.  
  17. uses
  18.    WinProcs, WinTypes, Objects, OWindows, OMemory,
  19.    ODialogs, Strings, bwcc, EXAMPLEc
  20.    {Regen_Uses}
  21.    {Regen_Uses}
  22.    ;
  23.  
  24. const
  25.    AppName: PChar = 'Example';
  26.  
  27.    {$I Example.inc}
  28.  
  29.    {Regen_Variables}
  30.    {Regen_Variables}
  31.  
  32.  
  33. type
  34.  
  35. {--------------- Main Window Object ---------------}
  36.  
  37.    PExample = ^TExample;
  38.    TExample = object(TApplication)
  39.       procedure   InitMainWindow; virtual;
  40.       procedure   InitInstance; virtual;
  41.       {Regen_AppClass}
  42.       {Regen_AppClass}
  43. end;
  44.  
  45. {--------------- Main Window of the application -------------------}
  46.  
  47.   PMainWindow = ^TMainWindow;
  48.   TMainWindow = object(TWindow)
  49.    constructor Init(AParent: PWindowsObject; ATitle: PChar);
  50.    destructor Done; virtual;
  51.    procedure CM_Example(var Msg: TMessage);
  52.      virtual cm_First + IDM_EXAMPLE;
  53.    procedure CM_Exit(var Msg: TMessage);
  54.      virtual cm_First + IDM_EXIT;
  55.    {Regen_MainClass}
  56.    {Regen_MainClass}
  57.  
  58.    procedure GetWindowClass(var AWndClass: TWndClass); virtual;
  59.    function  GetClassName: PChar; virtual;
  60. end;
  61.  
  62.  
  63. {Regen_Implementation}
  64. {Regen_Implementation}
  65.  
  66. procedure TExample.InitInstance;
  67. {Regen_ExampleInitVar}
  68. {Regen_ExampleInitVar}
  69. begin
  70.    inherited InitInstance;
  71.    HAccTable := LoadAccelerators(HInstance, 'MENU_1');
  72.   {Regen_Example_InitInstance}
  73.   {Regen_Example_InitInstance}
  74.  
  75. end;
  76.  
  77. constructor TMainWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  78. {Regen_MainInitVar}
  79. {Regen_MainInitVar}
  80. begin
  81.    inherited Init(AParent, ATitle);
  82.    Attr.Menu := LoadMenu(HInstance, 'MENU_1');
  83.    {Regen_MainConstruct}
  84.    {Regen_MainConstruct}
  85.  
  86. end;
  87.  
  88. {------------- Main Window Destructor ---------}
  89. destructor TMainWindow.Done;
  90. {Regen_MainDestVar}
  91. {Regen_MainDestVar}
  92. begin
  93.  
  94.    {Regen_MainDestruct}
  95.    {Regen_MainDestruct}
  96.  
  97.    inherited Done;
  98. end;
  99.  
  100. function TMainWindow.GetClassName : PChar;
  101. begin
  102.    GetClassName := 'EXAMPLE';
  103. end;
  104.  
  105. procedure TMainWindow.GetWindowClass(var AWndClass: TWndClass);
  106. {Regen_MainWinClassVar}
  107. {Regen_MainWinClassVar}
  108. begin
  109.    TWindow.GetWindowClass(AWndClass);
  110.    AWndClass.hbrBackground := CreateSolidBrush($80FFFF);
  111.    AWndClass.hIcon := LoadIcon(HInstance, 'EXAMPLE');
  112.    {Regen_ClassInfo}
  113.    {Regen_ClassInfo}
  114.  
  115. end;
  116.  
  117. {----------- Declare TDialog_1Dlg, a TDialog descendant ----------}
  118. type
  119. PTDialog_1Dlg = ^TDialog_1Dlg;
  120. TDialog_1Dlg = object(TDialog)
  121.  
  122.    constructor Init(AParent: PWindowsObject; AName: PChar);
  123.    destructor Done; virtual;
  124.    procedure WMInitDialog(var Msg: TMessage);
  125.      virtual wm_First + wm_InitDialog;
  126.    procedure RTDialog_1Idexample(var Msg: TMessage);
  127.      virtual id_First + idExample;
  128.    procedure Ok(var Msg: TMessage);
  129.      virtual id_First + IDOK;
  130.    procedure Cancel(var Msg: TMessage);
  131.      virtual id_First + IDCANCEL;
  132.    {Regen_Dialog_1_Class}
  133.    {Regen_Dialog_1_Class}
  134.  
  135. end;
  136.  
  137. {----------- Define TDialog_1Dlg, a TDialog constructor --------}
  138. constructor TDialog_1Dlg.Init(AParent: PWindowsObject; AName: PChar);
  139. {Regen_Dialog_1ConInitVar}
  140. {Regen_Dialog_1ConInitVar}
  141. begin
  142.    inherited Init(AParent, AName);
  143.    {Regen_Dialog_1_Constructor}
  144.    {Regen_Dialog_1_Constructor}
  145.  
  146. end;
  147.  
  148. {----------- Wm_InitDialog for TDialog_1Dlg --------}
  149. procedure TDialog_1Dlg.WMInitDialog(var Msg: TMessage);
  150. {Regen_Dialog_1WMInitVar}
  151. {Regen_Dialog_1WMInitVar}
  152. begin
  153.    inherited SetupWindow;
  154.    {Regen_Dialog_1_WmInitDlg}
  155.    {Regen_Dialog_1_WmInitDlg}
  156.  
  157. end;
  158.  
  159. {------------ Define TDialog_1Dlg destructor ----------}
  160. destructor TDialog_1Dlg.Done;
  161. {Regen_Dialog_1DestVar}
  162. {Regen_Dialog_1DestVar}
  163. begin
  164.    inherited Done;
  165.    {Regen_Dialog_1_Destructor}
  166.    {Regen_Dialog_1_Destructor}
  167.  
  168. end;
  169.  
  170. procedure TDialog_1Dlg.Ok(var Msg: TMessage);
  171. {Regen_Dialog_1IDOK_Var}
  172. {Regen_Dialog_1IDOK_Var}
  173. begin
  174.    {Regen_Dialog_1IDOK_Routing}
  175.    {Regen_Dialog_1IDOK_Routing}
  176.    inherited Ok(Msg);
  177. end;
  178.  
  179. procedure TDialog_1Dlg.Cancel(var Msg: TMessage);
  180. {Regen_Dialog_1IDCANCEL_Var}
  181. {Regen_Dialog_1IDCANCEL_Var}
  182. begin
  183.    {Regen_Dialog_1IDCANCEL_Routing}
  184.    {Regen_Dialog_1IDCANCEL_Routing}
  185.    inherited Cancel(Msg);
  186. end;
  187.  
  188. {----------- Declare TDialog_2Dlg, a TDialog descendant ----------}
  189. type
  190. PTDialog_2Dlg = ^TDialog_2Dlg;
  191. TDialog_2Dlg = object(TDialog)
  192.  
  193.    constructor Init(AParent: PWindowsObject; AName: PChar);
  194.    destructor Done; virtual;
  195.    procedure WMInitDialog(var Msg: TMessage);
  196.      virtual wm_First + wm_InitDialog;
  197.    procedure Ok(var Msg: TMessage);
  198.      virtual id_First + IDOK;
  199.    {Regen_Dialog_2_Class}
  200.    {Regen_Dialog_2_Class}
  201.  
  202. end;
  203.  
  204. {----------- Define TDialog_2Dlg, a TDialog constructor --------}
  205. constructor TDialog_2Dlg.Init(AParent: PWindowsObject; AName: PChar);
  206. {Regen_Dialog_2ConInitVar}
  207. {Regen_Dialog_2ConInitVar}
  208. begin
  209.    inherited Init(AParent, AName);
  210.    {Regen_Dialog_2_Constructor}
  211.    {Regen_Dialog_2_Constructor}
  212.  
  213. end;
  214.  
  215. {----------- Wm_InitDialog for TDialog_2Dlg --------}
  216. procedure TDialog_2Dlg.WMInitDialog(var Msg: TMessage);
  217. {Regen_Dialog_2WMInitVar}
  218. {Regen_Dialog_2WMInitVar}
  219. begin
  220.    inherited SetupWindow;
  221.    {Regen_Dialog_2_WmInitDlg}
  222.    {Regen_Dialog_2_WmInitDlg}
  223.  
  224. end;
  225.  
  226. {------------ Define TDialog_2Dlg destructor ----------}
  227. destructor TDialog_2Dlg.Done;
  228. {Regen_Dialog_2DestVar}
  229. {Regen_Dialog_2DestVar}
  230. begin
  231.    inherited Done;
  232.    {Regen_Dialog_2_Destructor}
  233.    {Regen_Dialog_2_Destructor}
  234.  
  235. end;
  236.  
  237. procedure TDialog_2Dlg.Ok(var Msg: TMessage);
  238. {Regen_Dialog_2IDOK_Var}
  239. {Regen_Dialog_2IDOK_Var}
  240. begin
  241.    {Regen_Dialog_2IDOK_Routing}
  242.    {Regen_Dialog_2IDOK_Routing}
  243.    inherited Ok(Msg);
  244. end;
  245.  
  246. procedure TMainWindow.CM_Example(var Msg: TMessage);
  247. {Regen_CMExampleVar}
  248. {Regen_CMExampleVar}
  249. begin
  250.    { Execute modal dialog }
  251.    if Application^.ExecDialog(
  252.           New(PTDialog_1Dlg, Init(@Self, 'DIALOG_1'))) = id_Ok then
  253.  
  254.       {Regen_EXAMPLE_Exec}
  255.       {Regen_EXAMPLE_Exec}
  256.  
  257. end;
  258.  
  259. procedure TMainWindow.CM_Exit(var Msg: TMessage);
  260. {Regen_CMExitVar}
  261. {Regen_CMExitVar}
  262. begin
  263.  
  264.       {Regen_EXIT_Exec}
  265.  
  266.       CloseWindow;
  267.  
  268.       {Regen_EXIT_Exec}
  269. end;
  270.  
  271. procedure TDialog_1Dlg.RTDialog_1Idexample(var Msg: TMessage);
  272. {Regen_Dialog_2Var}
  273. {Regen_Dialog_2Var}
  274. begin
  275.    { Execute modal dialog }
  276.    if Application^.ExecDialog(
  277.           New(PTDialog_2Dlg, Init(@Self, 'DIALOG_2'))) = id_Ok then
  278.  
  279.       {Regen_Dialog_2_Exec}
  280.       {Regen_Dialog_2_Exec}
  281. end;
  282.  
  283. { Create the application's main window }
  284. procedure TExample.InitMainWindow;
  285. {Regen_ExampleInitVar}
  286. {Regen_ExampleInitVar}
  287. begin
  288.  
  289.    MainWindow := New(PMainWindow, Init(nil, 'BWCC Button Demonstration'));
  290.    {Regen_MainCreate}
  291.    {Regen_MainCreate}
  292. end;
  293.  
  294. var
  295.   MainApp: TExample;
  296.  
  297. begin
  298.    {Regen_Init}
  299.    {Regen_Init}
  300.  
  301.    MainApp.Init('Example');
  302.    MainApp.Run;
  303.    MainApp.Done;
  304.  
  305.    {Regen_Cleanup}
  306.    {Regen_Cleanup}
  307. end.
  308.